cmake_minimum_required(VERSION 3.5)
project(fps_infer_node)

# 默认使用C99标准
if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

# 默认使用C++17标准
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 17)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# 引入 ament_cmake
find_package(ament_cmake REQUIRED)

# 查找依赖库
find_package(OpenCV REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(rclcpp REQUIRED)

# 设置 OpenVINO 的路径（假设 OpenVINO 安装在 /opt/intel/openvino_2024/ 路径下）
set(OPENVINO_DIR "/opt/intel/openvino_2024/runtime")

# 添加 OpenVINO 库和头文件路径
include_directories(
  ${OPENVINO_DIR}/include
)

link_directories(
  ${OPENVINO_DIR}/lib
)

# 添加可执行文件
add_executable(fps_infer_node
  src/fps_infer_node.cpp
)

# 添加目标依赖
ament_target_dependencies(
  fps_infer_node
  rclcpp
  OpenCV
  Eigen3
)

# 手动链接 OpenVINO 库
target_link_libraries(fps_infer_node
  ${OPENVINO_DIR}/lib/intel64/libopenvino.so  # OpenVINO runtime 库
  ${OpenCV_LIBS}
  Eigen3::Eigen
)

# 安装可执行文件
install(TARGETS fps_infer_node
  DESTINATION lib/${PROJECT_NAME}
)

# 安装配置文件
install(DIRECTORY
  models
  DESTINATION share/${PROJECT_NAME}
  OPTIONAL
)

install(DIRECTORY
  config
  DESTINATION share/${PROJECT_NAME}
  OPTIONAL
)

install(DIRECTORY
  launch
  DESTINATION share/${PROJECT_NAME}
  OPTIONAL
)

# 注册节点
ament_package()
